package com.alexgaoyh.MutiModule.Dubbo.RWSeperate.provider.read.${packageName};

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.MutiModule.common.myPage.MyPageView;
import com.MutiModule.common.myPage.util.MyPageViewUtilss;
import com.MutiModule.common.vo.mybatis.pagination.Page;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.api.${packageName}.read.I${className}ReadService;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.${packageName}.${className};
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.${packageName}.${className}Example;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.${packageName}.${className}Mapper;

@Service(value = "${smallClassName}Service")
public class ${className}ServiceImpl implements I${className}ReadService{
	
	@Resource(name = "${smallClassName}Mapper")
	private ${className}Mapper mapper;

	@Override
	public int countByExample(${className}Example example) {
		return mapper.countByExample(example);
	}

	@Override
	public List<${className}> selectByExample(${className}Example example) {
		return mapper.selectByExample(example);
	}

	@Override
	public ${className} selectByPrimaryKey(Long id) {
		return mapper.selectByPrimaryKey(id);
	}
	
	@Override
	public MyPageView<${className}> generateMyPageViewVO(${className}Example exampleWithOutPage, Page page) {
		
		int _totalCount = mapper.countByExample(exampleWithOutPage);
		
		exampleWithOutPage.setPage(page);
		
		List<${className}> _list = mapper.selectByExample(exampleWithOutPage);
		
		MyPageView<${className}> pageView = new MyPageViewUtilss<${className}>().generaterMyPageView(page.getLength(), page.getPageNo(), _totalCount, _list);
		
		return pageView;
	}

}
